package com.by.controller;

import com.by.bean.Audit;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.service.AuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/v1")
@Api(tags = "审核 ")
public class AuditController extends BaseController {
    @Autowired
    AuditService auditService;
    @ApiOperation("保存")
    @PostMapping("/audit/save")
    public ResultBean save(@RequestBody Audit audit){
        int rs=auditService.save(audit);
        return success("成功");
    }
    @ApiOperation("查看")
    @PostMapping("/audit/query")
    public ResultBean query(){
        List list=auditService.query();
        return success("成功",list);
    }
    @ApiOperation("更新状态")
    @PostMapping("/audit/updateStatus")
    public ResultBean updateStatus(@RequestBody Audit audit){
        int rs=auditService.updateStatus(audit);
        return success("成功",rs);
    }
    @ApiOperation("原因填写")
    @PostMapping("/audit/updateResult")
    public ResultBean updateResult(@RequestBody Audit audit){
        int rs=auditService.updateResult(audit);
        return success("成功",rs);
    }
    @ApiOperation("查看原因")
    @PostMapping("/audit/queryResult")
    public ResultBean queryResult( String id){
        String result=auditService.queryResult(id);
        return success("成功",result);
    }

}
